package com.anycc.cloud.common.entity;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

/**
 * UUID主键类
 */
@MappedSuperclass
public class UUIDEntity implements IdEntity<String> {
    private static final long serialVersionUID = -6875057344745136177L;
    public static final String FIELD_ID = "id";
    private String id;

    public UUIDEntity() {
    }

    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid2")
    @Column(name = "id", length = 36, nullable = false, unique = true)
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}
